package net.qhzw.vip.qiyu.domain.dto;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Arrays;
import java.util.Collection;

@Data
public class LoginUserDto implements UserDetails {

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 商铺ID
     */
    private Long shopId;

    /**
     * 1、系统管理员；2、站点管理员；3、微信用户
     */
    private Byte userType;

    private String username;

    private String password;

    private Byte status;

    public LoginUserDto() {

    }

    public LoginUserDto(Long userId, Long shopId, Byte userType, Byte status) {
        this.userId = userId;
        this.shopId = shopId;
        this.userType = userType;
        this.status = status;
    }

    public LoginUserDto(Long userId, String password, Byte status) {
        this.userId = userId;
        this.password = password;
        this.status = status;
    }


    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return Arrays.asList(new SimpleGrantedAuthority("ADMIN_USER"));
    }

    @Override
    public String getPassword() {
        return this.password;
    }

    @Override
    public String getUsername() {
        return this.username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return this.status == 1;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }


}
